﻿// DataTable Extensions from Finaquant Analytics
// Provided with the GNU General Public License (GPL)
// For license information see http://www.gnu.org/licenses/licenses.html
//
// Copyright ©  - Finaquant Analytics GmbH - http://finaquant.com/
// 
// NOTE: Non-commercial and free .net library Finaquant Protos
// which is required for these DataTable Extebsions
// can be downloaded at http://finaquant.com/FinaquantProtos
using FinaquantProtos;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace FinaquantDataTableExtensions
{
    /// <summary>
    /// Table viewer form
    /// </summary>
    public partial class TableViewer : Form
    {
        internal TableViewer(DataTable tbl, string Header)
        {
            InitializeComponent();
            this.Text = Header + " - finaquant.com";

            // set read-only (view) properties
            dataGridView1.AllowUserToAddRows = false;
            dataGridView1.AllowUserToDeleteRows = false;
            dataGridView1.AllowUserToOrderColumns = false;
            dataGridView1.ReadOnly = true;
            dataGridView1.RowHeadersVisible = false;
            // dataGridView1.BackgroundColor = Color.Turquoise;

            // bind DataTable to GridView
            dataGridView1.DataSource = tbl;
        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            DataTable tbl = (DataTable) dataGridView1.DataSource;
            // System.Diagnostics.Debug.WriteLine(tbl.FQ_ConvertToString());

            tbl.FQ_ExportToCSVfile();
        }

        private void TableViewer_Load(object sender, EventArgs e)
        {

        }
    }
}
